﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using LibraryBLL.BookBLL;
using LibraryModels;

namespace WebAppLibrary.Form
{
    public partial class OpenBook : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                OpenBooks();
            }
        }
        /// <summary>
        /// 借书操作    
        /// </summary>
        private void OpenBooks()
        {
            OpenBookInfoBLL objBookBll = new OpenBookInfoBLL();
            TabBorrowBooks objBook = new  TabBorrowBooks();
            try
            {
                //得到表单提交的值
                objBook.BookID = int.Parse(Request.Form["Number"].ToString());
                objBook.UserID = 1;
                objBook.StartTime = Request.Form["starttime"].ToString();
                objBook.EndTime = Request.Form["endtime"].ToString();
                objBook.Remark = Request.Form["remark"];
                string json;
                //如果success为true,则表示服务器端处理成功
                if (objBookBll.OpenBook(objBook) > 0)
                {
                    json = @"{success: true}";
                }
                else
                {
                    json = @"{success: false}";
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
    }
}
